package jltx.fragmentpageframework.simple.fragment.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;

import cn.jltx.support.SupportFragment;
import cn.jltx.utils.ViewHelper;
import jltx.fragmentpageframework.R;

/**
 * @author jltxseo
 *         Created by junlintianxia on 2017/05/22.
 */

public class BaseFragment extends SupportFragment{
    private int toolTitleId = -1;
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        setToolbarTitle(toolTitleId);
    }

    public void setToolbarTitle(int titleId){
        toolTitleId = titleId;
        Toolbar toolbar = ViewHelper.findViewById(getView(),R.id.toolbar);
        if(toolbar != null){
            toolbar.setTitle(titleId);
        }
    }

    protected void initToolbarMenu(Toolbar toolbar) {
        toolbar.inflateMenu(R.menu.hierarchy);
        toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.action_hierarchy:
//                        _mActivity.showFragmentStackHierarchyView();
//                        _mActivity.logFragmentStackHierarchy(TAG);
                        break;
                }
                return true;
            }
        });
    }
}
